//
//  String+subscript.swift
//  yihuiwang_ios
//
//  Created by 张衡 on 2020/11/16.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

extension String {
    public func `subscript`(bounds: CountableRange<Int>) -> String {
        let string = self[index(startIndex, offsetBy: bounds.lowerBound) ..< index(startIndex, offsetBy: bounds.upperBound)]
        return String(string)
    }
    
    public func `subscript`(bounds: CountableClosedRange<Int>) -> String {
        let string = self[index(startIndex, offsetBy: bounds.lowerBound) ... index(startIndex, offsetBy: bounds.upperBound)]
        return String(string)
    }
  
    public func `subscript`(index: Int) -> String {
    let character = self[self.index(startIndex, offsetBy: index)]
    return String(character)
    }
}
